#!/usr/bin/env bash
###############################################################################
# Copyright (c) 2020, 2022 Eurotech and/or its affiliates and others
#
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
#     Eurotech - initial API and implementation
###############################################################################

#
# This script destroys the Keycloak project
#

set -e

# Commons

. "${BASH_SOURCE%/*}/env"
. "${BASH_SOURCE%/*}/functions"
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
. ${SCRIPT_DIR}/../openshift-common.sh

### Remove Keycloak

echo "Undeploying Keycloak from Openshift"

${OC} login --username=${OPENSHIFT_USER} --password=${OPENSHIFT_PASS} ${OPENSHIFT_LOGIN_OPTS} &>/dev/null

${OC} delete project "${KEYCLOAK_PROJECT_NAME}"

echo "Eclipse Keycloak undeployed from Openshift"
